package com.common.function.file;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class FileProcessor {
    public void processFileToUpper(String filename) throws IOException {
        try (BufferedReader reader = new BufferedReader(new FileReader(filename))) {
            String line;
            while ((line = reader.readLine()) != null) {
                String processedLine = line.toUpperCase();
                System.out.println(processedLine); // 可替换为具体处理逻辑，比如写入到另一个文件
            }
        }
    }

    public void processFileToLower(String filename) throws IOException {
        try (BufferedReader reader = new BufferedReader(new FileReader(filename))) {
            String line;
            while ((line = reader.readLine()) != null) {
                String processedLine = line.toLowerCase();
                System.out.println(processedLine); // 可替换为具体处理逻辑，比如写入到另一个文件
            }
        }
    }

    public void processFileEncrypt(String filename) throws IOException {
        try (BufferedReader reader = new BufferedReader(new FileReader(filename))) {
            String line;
            while ((line = reader.readLine()) != null) {
                // 这里只是演示，实际的加密算法应该更复杂
                String processedLine = line.replaceAll("[a-zA-Z]", "*");
                System.out.println(processedLine); // 可替换为具体处理逻辑，比如写入到另一个文件
            }
        }
    }
}